package jp.eisbahn.mgapi.api.groups;

import java.io.InputStream;
import java.util.Map;

import jp.eisbahn.mgapi.api.AbstractPagingRequest;
import jp.eisbahn.mgapi.api.Response;
import jp.eisbahn.mgapi.http.ContentType;
import jp.eisbahn.mgapi.http.HttpMethod;
import jp.eisbahn.mgapi.http.HttpUtils;

/**
 * The request class to retrieve the group information with Groups API.
 * @author Yoichiro Tanaka
 */
public class GroupRequest extends AbstractPagingRequest {

    /** The base URI string. */
    private static final String BASE_URI = "/groups/{userId}";

    /** The user ID. */
    private String userId;

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getUri()
     */
    @Override
    public final String getUri() {
        String query = HttpUtils.createQueryParameterString(
                getStartIndexQueryParameter(),
                getCountQueryParameter()
        );
        return BASE_URI.replace("{userId}", userId) + "?" + query;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getHttpMethod()
     */
    @Override
    public final HttpMethod getHttpMethod() {
        return HttpMethod.GET;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getResponseClass()
     */
    @Override
    public final Class<? extends Response> getResponseClass() {
        return GroupsResponse.class;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getContentType()
     */
    @Override
    public final ContentType getContentType() {
        return ContentType.X_WWW_FORM_URLENCODED;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getBodyStream()
     */
    @Override
    public final InputStream getBodyStream() {
        return null;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getParameterMap()
     */
    @Override
    public final Map<String, Object> getParameterMap() {
        return null;
    }

    /*
     * (non-Javadoc)
     * @see jp.eisbahn.mgapi.api.Request#getHeaderMap()
     */
    @Override
    public final Map<String, String> getHeaderMap() {
        return null;
    }

    /**
     * Set the user ID.
     * @param theUserId The user ID.
     */
    public final void setUserId(final String theUserId) {
        userId = theUserId;
    }

    /**
     * Retrieve the user ID.
     * @return The user ID.
     */
    public final String getUserId() {
        return userId;
    }

}
